#!/bin/sh
preinstall=(zsh delta neovim procs starship nodejs)
for i in ${preinstall[@]}
do 
    echo "installing $i"
    case $i in
        zsh)
            if [ ! `which zsh` ];then
                sudo apt install zsh -y
            fi
            ;;
        delta)
            if [ ! `which delta` ];then
                wget https://github.com/dandavison/delta/releases/download/0.9.2/git-delta-musl_0.9.2_amd64.deb
                sudo dpkg -i git-delta-musl_0.9.2_amd64.deb
                rm gitgit-delta-musl_0.9.2_amd64.deb 
            fi
            ;;
        neovim)
            if [ ! `which neovim` ];then
                sudo apt install neovim -y
            fi
            ;;
        procs)
            if [ ! `which procs`];then
                wget -q --show-progress https://github.com/dalance/procs/releases/download/v0.11.9/procs-v0.11.9-x86_64-lnx.zip 
                unzip procs-v0.11.9-x86_64-lnx.zip
                sudo mv procs /usr/local/bin
                rm procs-v0.11.9-x86_64-lnx.zip
            fi
            ;;
        starship)
            if [ ! `which starship` ];then
                wget -q --show-progress https://github.com/starship/starship/releases/latest/download/starship-x86_64-unknown-linux-musl.tar.gz
                tar xf starship-x86_64-unknown-linux-musl.tar.gz
                sudo mv starship /usr/local/bin/
                rm starship-x86_64-unknown-linux-musl.tar.gz
            fi
            ;;
        nodejs)
            if [ ! `which node` ];then
                sudo apt -y install curl dirmngr apt-transport-https lsb-release ca-certificates
                curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
                sudo apt -y install nodejs
            fi
            ;;
        zinit)
            if [ ! `which zinit` ];then
                mkdir -p "$HOME/.zinit" && chmod g-rwX "$HOME/.zinit"
                git clone https://github.com/zdharma-continuum/zinit "$HOME/.zinit/bin"
            fi
            ;;
        *)
            echo "$i had installed!"
    esac
done